<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="stylesheet" type="text/css" href="${ctx}/static/plug/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="${ctx}/static/plug/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="${ctx}/static/plug/Hui-iconfont/1.0.8/iconfont.css" />
<link rel="stylesheet" type="text/css" href="${ctx}/static/plug/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css" href="${ctx}/static/plug/h-ui.admin/css/style.css" />
<style type="text/css">
.Hui-iconfont{
	text-decoration: underline;
}
</style>
<title>景区管理</title>
</head>
<body>
	<div class="page-container">
		<div> 
			<div>
				<input type="text" id="name" placeholder="景区名" style="width:250px" class="input-text">
				<button class="btn btn-success" type="submit" onclick="reloadData()"><i class="Hui-iconfont">&#xe665;</i> 搜索</button>
			</div>
		</div>
		<div class="cl pd-5 bg-1 bk-gray mt-20">
			<span class="l"> 
				<a href="javascript:;" onclick="addOrUpdate('添加景区','${ctx}/scenicSpot/saveOrUpdateIndex','1150','370')" class="btn btn-primary radius">
					<i class="Hui-iconfont">&#xe600;</i> 添加景区
				</a>
			</span>
		</div>
		<div class="mt-20">
			<table id="dataTable" class="table table-border table-bordered table-hover table-bg table-sort">
				<thead>
					<tr class="text-c">
						<th width="10%">名称</th>
						<th width="5%">位置</th>
						<th width="10%">公众号appId</th>
						<th width="10%">公众号accountId</th>
						<th width="10%">支付公众号appId</th>
						<th width="10%">支付公众号accountId</th>
						<th width="10%">支付公众号paySecretKey</th>
						<th width="10%">支付公众号商户号</th>
						<th width="10%">支付公众号支付证书</th>
						<th width="10%">操作</th>
					</tr>
				</thead>
				<tbody>
				</tbody>
			</table>
		</div>
	</div>
	<!--请在下方写此页面业务相关的脚本-->
	<script type="text/javascript" src="${ctx}/static/plug/My97DatePicker/4.8/WdatePicker.js"></script>
	<script type="text/javascript" src="${ctx}/static/plug/datatables/1.10.0/jquery.dataTables.min.js"></script>
	<script type="text/javascript" src="${ctx}/static/plug/laypage/1.2/laypage.js"></script>
	<script type="text/javascript">
		var dataTable;
		$(function() {
			dataTable = $("#dataTable").DataTable($.extend(true, {}, TABLE_CONSTANT.DATA_TABLES.DEFAULT_OPTION, {
				"ajax" : function(data, callback, settings) {
					var param = getQueryParam(data);
					$.ajax({
						type : "POST",
						url : "${ctx}/scenicSpot/list",
						cache : false, //禁用缓存
						data : param, //传入已封装的参数
						dataType : "json",
						success : function(result) {
							callback(result);
						},
						error : function(XMLHttpRequest, textStatus, errorThrown) {
							alert("查询失败");
						}
					});
				},
				"columns" : [{
					"data" : "name"
				},{
					"data" : "area"
				},{
					"data" : "appId"
				},{
					"data" : "accountId"
				},{
					"data" : "payAppId"
				},{
					"data" : "payAccountId"
				},{
					"data" : "paySecretKey"
				},{
					"data" : "payMchId"
				},{
					"data" : null
				},{
					"data" : null
				}],
				"columnDefs" : [ {
					targets : 8,
					render : function(a, b, c, d) {
						var html = c.payCertPath.length > 0 ? '已上传' : '未上传';
						return html;
					}
				} ,{
					targets : 9,
					render : function(a, b, c, d) {
						var html = genOperatirHtml(c.id);
						return html;
					}
				} ]
			}));
		});

		function genOperatirHtml(id) {
			var html = "";
			html += "<a title=\"编辑\" href=\"javascript:;\" onclick=\"addOrUpdate('编辑','${ctx}/scenicSpot/saveOrUpdateIndex?scenicSpotId="
				+ id + "','1150','370')\" class=\"ml-5\" style=\"text-decoration:none\">";
			html += "<i class=\"Hui-iconfont\">编辑</i></a> ";
			return html;
		}
		

		function getQueryParam(data) {
			var param = {};
			var name = $("#name").val();
			if (name) {
				param.name = name;
			}

			//自定义的查询条件 后面加
			param.draw = data.draw;
			param.startIndex = data.start;
			param.pageSize = data.length;
			return param;
		}

		function reloadData(resetPage) {
			dataTable.ajax.reload(null,resetPage);
		}
		
		function addOrUpdate(title,url,width,height) {
			layer_show(title,url,width,height);
		}
	</script>
</body>
</html>
